package com.eastcom.collection.provider
import com.eastcom.collection.config.FtpTaskConfig;
import com.eastcom.collection.tools.file.JaxbUtil;
import com.eastcom.collection.tools.rmi.ift.ITaskSender

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

public class RmiClientProvider {
	private String rmiServiceAddr;
	private int rmiServicePort;
	private String rmiServiceName;
	private Object resource
	public String getRmiServiceAddr() {
		return rmiServiceAddr;
	}
	public void setRmiServiceAddr(String rmiServiceAddr) {
		this.rmiServiceAddr = rmiServiceAddr;
	}
	public int getRmiServicePort() {
		return rmiServicePort;
	}
	public void setRmiServicePort(int rmiServicePort) {
		this.rmiServicePort = rmiServicePort;
	}
	public String getRmiServiceName() {
		return rmiServiceName;
	}
	public void setRmiServiceName(String rmiServiceName) {
		this.rmiServiceName = rmiServiceName;
	}

	public Object getRmiResource() throws MalformedURLException, RemoteException, NotBoundException{
		String url=new StringBuilder("rmi://")
		.append(rmiServiceAddr).append(":")
		.append(rmiServicePort).append("/")
		.append(rmiServiceName).toString();
		return Naming.lookup(url);
	}


	public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException, InterruptedException{
		RmiClientProvider client = new RmiClientProvider();
		client.setRmiServiceAddr("127.0.0.1");
		client.setRmiServicePort(10100);
		client.setRmiServiceName("mystope_server");
		System.out.println(client);
		Object inf=client.getRmiResource();
		System.out.println(inf);
		ITaskSender tg = inf
		FtpTaskConfig ty = JaxbUtil.converyFileToJavaBean("E:\\我的工程文档\\上海诺西SGSN37新的性能采集\\统一采集\\NRM-GGSN(V3.2.0)_20100429.xml", "UTF-8", FtpTaskConfig.class)
//		FtpTaskConfig ty = JaxbUtil.converyFileToJavaBean(args[0], "UTF-8", FtpTaskConfig.class)
		
		String xml = JaxbUtil.convertToXmlFile(ty)
		println xml
		println tg.send(xml)
	}
	
}
